<template>
  <div class="header">
    <div class="tag">
      <!-- <div>智慧用电管控平台</div> -->
    </div>
    <div class="peg">
      <div class="weather">
        <!-- <div>天气</div>
        <div>晴</div> -->
      </div>
      <div class="logo">
        <img src="@/assets/images/logo-33px.png" alt="" />
        <div>智慧用电管控平台</div>
      </div>
    </div>
    <div v-if="isTitle" class="operate">
      <div class="time">
        <div>{{ newtime }}</div>
      </div>
      <el-dropdown :show-timeout="1000">
        <div class="backhome" @click="$router.go(-1)">
          <img src="@/assets/images/ico_back_red.png" alt="" />
          <div>返回上级</div>
        </div>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>
              <div
                style="display: flex; align-items: center"
                @click.stop="$router.push('/welcome')"
              >
                <img
                  src="@/assets/images/ico_home.png"
                  alt="返回系统"
                  style="padding-right: 5px"
                />
                <span>返回系统</span>
              </div>
            </el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>

      <div class="user">
        <img src="@/assets/images/ico_user_red.png" alt="user" />
        <div>Admin</div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
import dayjs from "dayjs";

const props = defineProps({
  isTitle: {
    type: Boolean,
    default: true
  }
});

let newtime = ref();
newtime.value = dayjs().format("YYYY-MM-DD HH:mm:ss");
setInterval(() => {
  newtime.value = dayjs().format("YYYY-MM-DD HH:mm:ss");
}, 1000);
</script>

<style scoped lang="scss">
.header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 2;
  display: flex;
  // justify-content: space-between;
  align-items: center;
  height: 76px;

  .tag {
    width: 100%;
    height: 76px;
    // background-image: url("@/assets/images/img_heat_bg.png");
    background-image: url("@/assets/images/img_heat_bg_red.png");
    background-size: 100% 100%;

    div {
      // padding-top: 14px;
      padding-top: 19px;
      // font-size: 40px;
      font-size: 36px;
      font-weight: bold;
      // line-height: 40px;
      line-height: 36px;
      // color: #0759d2;
      color: #000;
      text-align: center;
      // text-shadow: 0 2px 3px rgb(9 35 51 / 21%);
      // letter-spacing: 0;
    }
  }

  .peg {
    position: fixed;
    // top: 37px;
    top: auto;
    left: 24px;
    display: flex;
    align-items: center;
    font-size: 16px;
    color: #374752;
    white-space: nowrap;

    .weather {
      display: flex;
      align-items: center;

      div {
        &:nth-child(1) {
          margin-right: 12px;
        }

        &:nth-child(2) {
          color: #2693e1;
        }
      }
    }

    .logo {
      display: flex;
      align-items: center;

      div {
        font-size: 36px;
        font-weight: bold;
        line-height: 36px;
        color: #000;
        text-align: center;
        margin-left: 15px;
      }
    }
  }

  .operate {
    position: fixed;
    top: 38px;
    right: 35px;
    display: flex;
    align-items: center;
    font-size: 16px;
    line-height: 16px;
    color: #374752;
    white-space: nowrap;

    .time {
      margin-right: 27px;
    }

    .backhome {
      cursor: pointer;
      display: flex;
      align-items: flex-end;

      div {
        font-size: 16px;
        line-height: 16px;
      }

      img {
        margin-right: 8px;
        // width: 19px;
        height: 19px;
      }
    }

    .user {
      display: flex;
      align-items: center;
      margin-left: 25px;
      font-size: 16px;
      cursor: pointer;

      img {
        width: 19px;
        height: 19px;
        margin-right: 7px;
      }
    }
  }
}
</style>
